/*
 * @Author: 9ilk 3535851673@qq.com
 * @Date: 2025-01-11 15:59:47
 * @LastEditors: 9ilk 3535851673@qq.com
 * @LastEditTime: 2025-01-11 16:49:58
 * @FilePath: /zhuang/DictServer/Common.hpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

#pragma once
#include<iostream>
#include<string>
#define Die(code) do{exit(code);}while(0)
#define CONV(v) ( struct sockaddr*)(v) //强转
using namespace std;

enum
{
  USAGE_ERR=1,
  SOCKET_ERR,
  BIND_ERR
};

bool SplitString(const string& line,string *key, string* value,const string& sep) //切分字符串的方法
{
   auto pos = line.find(sep); //找分割符
   if(pos == string::npos)  return false;//没找到分割符
   *key = line.substr(0,pos);
   *value = line.substr(pos+sep.size());
   if(key->empty() || key->empty()) return false; //有一个是空窜
   return true;
}
